<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<script src="<%=basePath%>/js/jquery.js"></script>
<script>
    function login(){
        $.ajax({
            type:"POST",
            url : "<%=basePath%>user/login.do",
            data : {
                userName : $(".userName").val(),
                password : $(".password").val()
            },
            success : function(meg) {
               if(meg =="ok"){
                   window.location="<%=basePath%>user/main.do";
                }else{
                   $("#message").text(meg);
                }
            },
            error:function (XMLHttpRequest, textStatus, errorThrown) {
                alert("网络错误");
            }

        });
    }
</script>
<head>
    <title>Title</title>
</head>
<body>

        1用户名<input class="userName" type="text">
        22密码 <input class="password" type="password"><span id="message"></span>
        <button  onclick="login()">登录</button>

</body>
</html>
